package com.skywalker.common.plugin.j2cache;

import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.cache.ICache;

/**
 * @user: skywalker
 * @date: 2019/4/13 21:31
 * @description:
 */
public class J2Cache implements ICache {
    @Override
    public <T> T get(String cacheName, Object key) {
        return J2CacheKit.get(cacheName, key);
    }

    @Override
    public void put(String cacheName, Object key, Object value) {
        J2CacheKit.put(cacheName, key, value);
    }

    @Override
    public void remove(String cacheName, Object key) {
        if (key instanceof String && StrKit.notBlank(key.toString())) {
            J2CacheKit.remove(cacheName, key.toString());
        }
    }

    @Override
    public void removeAll(String cacheName) {
        J2CacheKit.removeAll(cacheName);
    }
}
